package com.dnd.monitor.strategy.context;

import com.dnd.monitor.common.enums.AreaEnum;
import com.dnd.monitor.entity.DocumentNumberCalc;
import com.dnd.monitor.strategy.AreaExecuteStrategy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Author 安贺
 * @CreateTime 2022年08月10日 09:34:00
 * @Description: 策略
 */
@Service
@Slf4j
public class StrategyContext {

    @Autowired
    private Map<String, AreaExecuteStrategy> areaExecuteStrategyMap;

    /**
     * 执行策略
     * @param calcList 列表
     * @param areaEnum 地区
     * @return
     */
    public void executeStrategy(List<DocumentNumberCalc> calcList, AreaEnum areaEnum){
        try {
            areaExecuteStrategyMap.get(areaEnum.getStrategy()).execute(calcList);
        }catch (Exception e){
           e.printStackTrace();
        }
    }
}
